﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TemplateWeb.Models.ViewModels.GroupViewModel>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<%
    var lstPhien = Model.PhienDauGiaModel.GetModel.LstObjModel.Where(n => n.XuatHienOTrangChu && n.Duyet && n.ThoiGianBatDau <= DateTime.Now && DateTime.Now <= n.ThoiGianKetThuc).ToList();
    var lstPhienKieuAnh = lstPhien.Where(n => n.HinhThucDauGia.TenHinhThucDauGia.ToUpper().Contains("ANH")).ToList();
    var lstPhienNguoc = lstPhien.Where(n => !n.HinhThucDauGia.TenHinhThucDauGia.ToUpper().Contains("ANH")).ToList();
%>

<script type="text/javascript">
    window.onload = function () {
        <% for(int i=0; i<lstPhien.Count; i++){ %>
            StartCountDown("clock-" + <%= lstPhien[i].ID.ToString() %>, "<%= lstPhien[i].ThoiGianKetThuc.ToString() %>");
        <% } %>
    }

    <% if (ViewData["infotxt"] != null && ViewData["infotxt"] != string.Empty)
       { %>
        alert("<%= ViewData["infotxt"] %>");
    <% } %>
</script>


<!-- MAIN CONTAINER -->
<div id="ja-mainbody" style="width:80%">
    <!-- CONTENT -->
    <div id="ja-main" style="width:100%">
	    <div id="ja-contentwrap" class="">
			<div id="ja-content" class="column" style="width:100%">
                <div id="ja-current-content" class="column" style="width:100%">
                    <div class="ja-content-main clearfix">
                        <!-- Dau gia kieu Anh -->
                        <div class="dinhngochoapro">
                            <div id="auction_order_header">
                                <span style="font-size: 14px; font-weight: bold;">Đấu giá kiểu Anh</span>
                            </div>
                            <div width="100%" class="auction_list_container">
                            <% if (lstPhienKieuAnh.Count > 0)
                                { %>
                                <% foreach (var phien in lstPhienKieuAnh)
                                    { %>
                                    <div width="20%" class="auction_grid_row">
                                        <div class="k1">
    	                                    <div class="tieude1">
    		                                    <%= phien.SanPham.TenSanPham%>
    	                                    </div>
                                            <div class="k2">
    	                                        <div id="auction_thumb_list" align="center">
                                                    <img src="../../Content/Images/Items/<%= phien.SanPham.HinhAnh %>" alt="<%= phien.SanPham.TenSanPham %>" border="0" />   
                                                </div>
                                                <div id="auction_price">                    
                                                    <span>Khởi điểm:</span>&nbsp;<b><%= string.Format("{0:0,0}", phien.GiaKhoiDiem)%> VNĐ</b>
                                                </div>
    	                                        <div id="auction_bin">
                                                    <span>Hiện tại:</span>&nbsp;
    			                                    <span id="Span2" style="color: red; font-size: 10pt;">
                                                        <%
                                                            // Lay gia hien tai
                                                            long giahientai = 0;
                                                            var lstNguoiChoiDauGia = phien.NguoiChoiDauGia.ToList();
                                                            if (lstNguoiChoiDauGia.Count > 0)
                                                            {
                                                                var giamax = (from n in lstNguoiChoiDauGia select n.GiaDuaRa).Max();
                                                                giahientai = giamax == null ? 0 : giamax;
                                                            }
                                                        %>
					                                    <%= giahientai == 0 ? "0" : string.Format("{0:0,0}", giahientai)%> VNĐ
                                                    </span>
                                                </div>
                                                <div>
                                                    <label id="clock-<%= phien.ID %>" style="color: red; font-size: 10pt; font-weight: bold;"></label>
                                                </div>
			                                    <div class="datcho2">
			                                        <div align="center">
				                                        <a class="btnAdvertise" onmouseover="this.className=&#39;btnAdvertiseOver&#39;" onmouseout="this.className=&#39;btnAdvertise&#39;" href="<%= Url.Action("DatChoDauGia", "Home", new { idphiendaugia = phien.ID }) %>"></a>
			                                        </div>
		                                        </div>
                                                </div>
                                        </div>
                                    </div> 
                                <% }
                                }
                                else
                                { %>
                                    Chưa có Phiên nào được đăng.. 
                             <% } %> 					                        	                 		  
                            </div>
                            <table align="center" width="100%">
                                <tbody>
                                    <tr>
                                        <td colspan="11" class="sectiontablefooter" style="font-weight: bold;"> 
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <!-- Dau gia nguoc -->
                        <div class="dinhngochoapro">
                            <div id="auction_order_header">
                                <span style="font-size: 14px; font-weight: bold;">Đấu giá ngược</span>
                            </div>
                            <div width="100%" class="auction_list_container">
                            <% if (lstPhienNguoc.Count > 0)
                               { %>
                                <% foreach (var phien in lstPhienNguoc)
                                    { %>
                                    <div width="20%" class="auction_grid_row">
                                        <div class="k1">
    	                                    <div class="tieude1">
    		                                    <%= phien.SanPham.TenSanPham%>
    	                                    </div>
                                            <div class="k2">
    	                                        <div id="auction_thumb_list" align="center">
                                                    <img src="../../Content/Images/Items/<%= phien.SanPham.HinhAnh %>" alt="<%= phien.SanPham.TenSanPham %>" border="0" />   
                                                </div>
                                                <div id="Div2">                    
                                                    <span>Lệ phí:</span>&nbsp;<b><%= string.Format("{0:0,0}", phien.TienDatCoc)%> VNĐ</b>
                                                </div>
                                                <div>
                                                    <label id="clock-<%= phien.ID %>" style="color: red; font-size: 10pt; font-weight: bold;"></label>
                                                </div>
			                                    <div class="datcho2">
			                                        <div align="center">
				                                        <a class="btnAdvertise" onmouseover="this.className=&#39;btnAdvertiseOver&#39;" onmouseout="this.className=&#39;btnAdvertise&#39;" href="<%= Url.Action("DatChoDauGia", "Home", new { idphiendaugia = phien.ID }) %>"></a>
			                                        </div>
		                                        </div>
                                                </div>
                                        </div>
                                    </div> 
                                <% }
                                }
                                else
                                { %>
                                    Chưa có Phiên nào được đăng.. 
                             <% } %>
                            </div>
                            <table align="center" width="100%">
                                <tbody>
                                    <tr>
                                        <td colspan="11" class="sectiontablefooter" style="font-weight: bold;"> 
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
				    </div>
				</div>
            </div>
        </div>
    </div>
</div>	
</asp:Content>
